angular.module('ceo.controllers', ['inventory.services'])

.controller('CeoCtrl', function($scope,$rootScope) {
})

//首页
.controller('HomeCtrl', function($scope,SalesService,FeedService,InventoryService) {
  $scope.$on('$ionicView.enter', function(e) {
		//获取今日销售数据
		SalesService.analytic($scope,{},function(data){
			$scope.saleAnalytics=data;
		});
		//获取库存数据
		InventoryService.overview($scope,{'qty': {$lt: 3}},function(data){
			$scope.inventoryStatus = data;
		});
		//拉取新闻
		var promFeed = FeedService.parseFeed();
		promFeed.then(function(data) {
			$scope.items = data; 
		},
		function() {
			$scope.items = {
				error: '数据加载失败...'
			};
		});
	});

})
//新闻
.controller('NewsCtrl', function($scope,$stateParams,FeedService) {
	$scope.item = FeedService.getOne($stateParams.newsId);
})

.controller('filterController', function($scope,$rootScope) {
	$rootScope.showDateFilter = function() {
		$rootScope.dateFilterShow = !$rootScope.dateFilterShow;
	};
	$rootScope.filterDate = function(date) {
		$rootScope.dateFilterShow = !$rootScope.dateFilterShow;
	};
})


.controller('PlaylistsCtrl', function($scope) {
})

.controller('PlaylistCtrl', function($scope, $stateParams) {
})
;
